/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package cz.vutbr.fit.xzemko01.tfmcbs.model.impl;

import cz.vutbr.fit.xzemko01.tfmcbs.model.Dependency;
import cz.vutbr.fit.xzemko01.tfmcbs.model.Entity;
import cz.vutbr.fit.xzemko01.tfmcbs.model.Generalization;

import cz.vutbr.fit.xzemko01.tfmcbs.model.meta.TfmcbsPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Entity</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link cz.vutbr.fit.xzemko01.tfmcbs.model.impl.EntityImpl#getDependsBy <em>Depends By</em>}</li>
 *   <li>{@link cz.vutbr.fit.xzemko01.tfmcbs.model.impl.EntityImpl#getDependsOn <em>Depends On</em>}</li>
 *   <li>{@link cz.vutbr.fit.xzemko01.tfmcbs.model.impl.EntityImpl#getExtends <em>Extends</em>}</li>
 *   <li>{@link cz.vutbr.fit.xzemko01.tfmcbs.model.impl.EntityImpl#getChilds <em>Childs</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class EntityImpl extends ElementImpl implements Entity {
	/**
	 * The cached value of the '{@link #getDependsBy() <em>Depends By</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDependsBy()
	 * @generated
	 * @ordered
	 */
	protected EList<Dependency> dependsBy;

	/**
	 * The cached value of the '{@link #getDependsOn() <em>Depends On</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDependsOn()
	 * @generated
	 * @ordered
	 */
	protected EList<Dependency> dependsOn;

	/**
	 * The cached value of the '{@link #getExtends() <em>Extends</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExtends()
	 * @generated
	 * @ordered
	 */
	protected EList<Generalization> extends_;

	/**
	 * The cached value of the '{@link #getChilds() <em>Childs</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getChilds()
	 * @generated
	 * @ordered
	 */
	protected EList<Generalization> childs;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EntityImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TfmcbsPackage.Literals.ENTITY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Dependency> getDependsBy() {
		if (dependsBy == null) {
			dependsBy = new EObjectWithInverseResolvingEList<Dependency>(Dependency.class, this, TfmcbsPackage.ENTITY__DEPENDS_BY, TfmcbsPackage.DEPENDENCY__TO);
		}
		return dependsBy;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Dependency> getDependsOn() {
		if (dependsOn == null) {
			dependsOn = new EObjectWithInverseResolvingEList<Dependency>(Dependency.class, this, TfmcbsPackage.ENTITY__DEPENDS_ON, TfmcbsPackage.DEPENDENCY__FROM);
		}
		return dependsOn;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Generalization> getExtends() {
		if (extends_ == null) {
			extends_ = new EObjectWithInverseResolvingEList<Generalization>(Generalization.class, this, TfmcbsPackage.ENTITY__EXTENDS, TfmcbsPackage.GENERALIZATION__CHILD);
		}
		return extends_;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Generalization> getChilds() {
		if (childs == null) {
			childs = new EObjectWithInverseResolvingEList<Generalization>(Generalization.class, this, TfmcbsPackage.ENTITY__CHILDS, TfmcbsPackage.GENERALIZATION__PARENT);
		}
		return childs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TfmcbsPackage.ENTITY__DEPENDS_BY:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getDependsBy()).basicAdd(otherEnd, msgs);
			case TfmcbsPackage.ENTITY__DEPENDS_ON:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getDependsOn()).basicAdd(otherEnd, msgs);
			case TfmcbsPackage.ENTITY__EXTENDS:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getExtends()).basicAdd(otherEnd, msgs);
			case TfmcbsPackage.ENTITY__CHILDS:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getChilds()).basicAdd(otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TfmcbsPackage.ENTITY__DEPENDS_BY:
				return ((InternalEList<?>)getDependsBy()).basicRemove(otherEnd, msgs);
			case TfmcbsPackage.ENTITY__DEPENDS_ON:
				return ((InternalEList<?>)getDependsOn()).basicRemove(otherEnd, msgs);
			case TfmcbsPackage.ENTITY__EXTENDS:
				return ((InternalEList<?>)getExtends()).basicRemove(otherEnd, msgs);
			case TfmcbsPackage.ENTITY__CHILDS:
				return ((InternalEList<?>)getChilds()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TfmcbsPackage.ENTITY__DEPENDS_BY:
				return getDependsBy();
			case TfmcbsPackage.ENTITY__DEPENDS_ON:
				return getDependsOn();
			case TfmcbsPackage.ENTITY__EXTENDS:
				return getExtends();
			case TfmcbsPackage.ENTITY__CHILDS:
				return getChilds();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TfmcbsPackage.ENTITY__DEPENDS_BY:
				getDependsBy().clear();
				getDependsBy().addAll((Collection<? extends Dependency>)newValue);
				return;
			case TfmcbsPackage.ENTITY__DEPENDS_ON:
				getDependsOn().clear();
				getDependsOn().addAll((Collection<? extends Dependency>)newValue);
				return;
			case TfmcbsPackage.ENTITY__EXTENDS:
				getExtends().clear();
				getExtends().addAll((Collection<? extends Generalization>)newValue);
				return;
			case TfmcbsPackage.ENTITY__CHILDS:
				getChilds().clear();
				getChilds().addAll((Collection<? extends Generalization>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TfmcbsPackage.ENTITY__DEPENDS_BY:
				getDependsBy().clear();
				return;
			case TfmcbsPackage.ENTITY__DEPENDS_ON:
				getDependsOn().clear();
				return;
			case TfmcbsPackage.ENTITY__EXTENDS:
				getExtends().clear();
				return;
			case TfmcbsPackage.ENTITY__CHILDS:
				getChilds().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TfmcbsPackage.ENTITY__DEPENDS_BY:
				return dependsBy != null && !dependsBy.isEmpty();
			case TfmcbsPackage.ENTITY__DEPENDS_ON:
				return dependsOn != null && !dependsOn.isEmpty();
			case TfmcbsPackage.ENTITY__EXTENDS:
				return extends_ != null && !extends_.isEmpty();
			case TfmcbsPackage.ENTITY__CHILDS:
				return childs != null && !childs.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //EntityImpl
